﻿@model rentit03_client.Controllers.UserViewModel
@using (Html.BeginForm("Save", "User", FormMethod.Post, new { @class = "form-horizontal" }))
{
    @Html.ValidationSummary(true)
    <fieldset>
        <legend>Required</legend>
        <div class="control-group">
            @Html.LabelFor(model => model.Email, new { @type = "email", @class = "control-label" })
            <div class="controls">
                @Html.TextBoxFor(model => model.Email, new { @required = "" })
                @Html.ValidationMessageFor(model => model.Email)
            </div>
        </div>
        <div class="control-group">
            @Html.LabelFor(model => model.Password, new { @class = "control-label" })
            <div class="controls">
                @Html.PasswordFor(model => model.Password, new { @required = "" })
                @Html.ValidationMessageFor(model => model.Password)
            </div>
        </div>
        <div class="control-group">
            @Html.LabelFor(model => model.ConfirmPassword, new { @class = "control-label" })
            <div class="controls">
                @Html.PasswordFor(model => model.ConfirmPassword, new { @required = "" })
            </div>
        </div>
    </fieldset>
    <fieldset>
        <legend>Details</legend>
        <div class="control-group">
            @Html.LabelFor(model => model.Name, new { @class = "control-label" })
            <div class="controls">
                @Html.TextBoxFor(model => model.Name)
            </div>
        </div>
        <div class="control-group">
            @Html.LabelFor(model => model.Phone, new { @class = "control-label" })
            <div class="controls">
                @Html.TextBoxFor(model => model.Phone)
            </div>
        </div>
        <div class="control-group">
            @Html.LabelFor(model => model.Address, new { @class = "control-label" })
            <div class="controls">
                @Html.TextAreaFor(model => model.Address, new { @rows = 3 })
            </div>
        </div>
        <div class="form-actions">
            @if (Model.UserId > 0)
            {
                <input name="UserId" type="hidden" value="@Model.UserId" />
            }
            <button type="submit" class="btn btn-primary">
                Save</button>
            @if (Model.UserId > 1)
            {
                @Html.ActionLink("Delete user", "Delete", "User", new { @id = Model.UserId }, new { @class = "btn btn-warning" })
            }
            @Html.ActionLink("Delete user", "Index", "User", new { @id = Model.UserId }, new { @class = "btn" })
        </div>
    </fieldset>
}